package com.example.myapplication.extensions

import android.content.Context
import com.example.myapplication.TAG_APP_FOREGROUND
import com.example.myapplication.TAG_APP_TOKEN
import com.example.myapplication.TAG_APP_USER_ID

class FileSharedPrefs(val context: Context) {

    private val prefs = context.getSharedPrefs()

    companion object {
        fun newInstance(context: Context) = FileSharedPrefs(context)
    }

    var token: String?
        get() = prefs.getString(TAG_APP_TOKEN, null)
        set(path) = prefs.edit().putString(TAG_APP_TOKEN, path).apply()

    var isForeGround: Boolean
        get() = prefs.getBoolean(TAG_APP_FOREGROUND, false)
        set(value) = prefs.edit().putBoolean(TAG_APP_FOREGROUND, value).apply()

    var userId: Int
        get() = prefs.getInt(TAG_APP_USER_ID, -1)
        set(path) = prefs.edit().putInt(TAG_APP_USER_ID, path).apply()

}
